'use strict';

const Controller = require('egg').Controller;

class CollectController extends Controller {
  
  async getCategorieList() {
    const { ctx } = this;
    const [ list ] = await ctx.service.cms.getCategorieList();

    ctx.body = {
      success: true,
      list,
    };
  }

  async getCollectList() {
    const { ctx } = this;
    const collectList = await ctx.service.collect.getCollectList(
      'TOPIC_LIST'
    );
    ctx.body = {
      success: true,
      collectList,
    };
  }

  async create(ctx) {
    const body = ctx.request.body;
    // 储存新主题帖
    const collect = await ctx.service.collect.newAndSave(
      body.title,
      body.biz,
    );
    ctx.body = {
      success: true,
      collect_id: collect.id,
    };
  }
}

module.exports = CollectController;

